package com.example.demo.config.rabbitMq;

import com.example.demo.RabbitMQTest.util.MQConstant;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


/**
 * 队列配置
 */
@Configuration
public class QueueConfiguration {

    @Autowired
    @Qualifier("defaultDirectExchange")
    private DirectExchange exchange;


    @Bean
    public Queue helloQueue() {
        return new Queue(MQConstant.QUEUE_HELLO_NAME,true,false,false);
    }

    @Bean
    public Queue adoptOrderQueue() {
        return new Queue(MQConstant.ADOPT_ORDER_NAME,true,false,false);
    }

    @Bean
    public Queue tourOrderQueue() {
        return new Queue(MQConstant.TOUR_ORDER_NAME,true,false,false);
    }

    @Bean
    public Binding helloBinding() {
        return BindingBuilder.bind(helloQueue()).to(exchange).with(MQConstant.QUEUE_HELLO_NAME);
    }

    @Bean
    public Binding adoptOrderBinding() {
        return BindingBuilder.bind(adoptOrderQueue()).to(exchange).with(MQConstant.ADOPT_ORDER_NAME);
    }

    @Bean
    public Binding tourOrderBinding() {
        return BindingBuilder.bind(tourOrderQueue()).to(exchange).with(MQConstant.TOUR_ORDER_NAME);
    }

}
